<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>分享</title>
		<meta name="Description" content="" />
		<meta name="Keywords" content="" />
		<meta name="format-detection" content="telephone=no, email=no" />
		<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
		<!-- 忽略页面中的数字识别为电话，忽略email识别 -->
		<meta name="applicable-device" content="mobile" />
		<meta name="apple-mobile-web-app-title" content="" />
		<!-- 添加到主屏后的标题（iOS 6 新增） -->
		<meta name="apple-mobile-web-app-capable" content="yes" />
		<!-- 是否启用 WebApp 全屏模式 -->
		<meta name="HandheldFriendly" content="true" />
		<!-- 针对手持设备优化，主要是针对一些老的不识别viewport的浏览器，比如黑莓 -->
		<meta name="author" content="Jack" />
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<script src="../../js/flexible.js" type="text/javascript" charset="utf-8"></script>
		<link rel="stylesheet" type="text/css" href="../../style/jquery_css/weui.css" />
		<link rel="stylesheet" type="text/css" href="../../style/jquery_css/jquery-weui.css" />
		<link rel="stylesheet" type="text/css" href="../../style/icon_font/iconfont.css" />
		<link rel="stylesheet" type="text/css" href="../../style/main.css" />
		<link rel="stylesheet" type="text/css" href="../../style/car.css" />
		<link rel="stylesheet" type="text/css" href="../../style/icon.css"/>
	</head>
	<body>
		<div>
			<div class="header-nav">
				<div class="cen-mony">
					<div class="header-flex">
						<i class="return-2" onclick="window.history.go(-1)"></i>
					</div>
					<div class="header-flex">分享</div>
					<div class="header-flex"></div>
				</div>
			</div>
			
			<div class="share-nav">
				<!-- <a href="javascript:;"><span class="active-span" onclick="share_type(1)">商城分享</span></a>
				<a href="javascript:;" onclick="share_type(2)"><span>系统分享</span></a> -->
			</div>
			
			<div class="share-box">
				<div class="share-pople-flex" onclick="shareList()">
					<div class="left-color">直推（人）</div>
					<div id="drive"></div>
				</div>
			</div>
			<div class="share-box">
				<div class="share-pople-flex">
					<div class="left-color">团队（人）</div>
					<div id="grup"></div>
				</div>
			</div>
			<!-- <div class="share-box">
				<div class="share-pople-flex">
					<div class="left-color">收入（元）</div>
					<div id="income"></div>
				</div>
			</div> -->
			
			<div class="invite-bg">
				<div class="invite-friend">
					<div class="friend-steward">邀请好友加入海门通信</div>
					<div class="invite-code">
						邀请码：<span class="code" id="invitation"></span>
						<span class="copy-bt" onclick="copy_fn('invitation')">复制</span>
					</div>
				</div>
			</div>
			
		</div>
	</body>
	<script src="../../js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
	<script src="../../js/weiUI/jquery-weui.min.js" type="text/javascript" charset="utf-8"></script>
	<script src="../../js/api/api_url.js" type="text/javascript" charset="utf-8"></script>
	<script src="../../js/api/port_url.js" type="text/javascript" charset="utf-8"></script>
	<script type="text/javascript">
		var user_arr = JSON.parse(sessionStorage.getItem('users_info'));
		
		$(function(){
			share_type(1);
		})
		
		function share_type(type){
			$.ajax({
					url: config_URL.api + URL.shareNum, //请求的url地址
					dataType: "json", //返回格式为json
					data: {
						access_token: '41ab23e7efb238797fe39cc30f6b21d3',
						user_token:user_arr.user_token,
						user_id:user_arr.id,
						type:type
					},
					type: "POST", //请求方式
					success: function(res) {
						console.log(res);
						var data = res.data;
						if(res.code == 0) {
							$('#drive').html(data.share);
							$('#grup').html(data.shareAll);
							$('#income').html(data.shareMoney);
							$('.code').html(data.invitation);						
						} else {
							$.toast(res.msg, "text");
						}

					},
					error: function(rul) {
						console.log('网络出错')
					}
				});
		}
		
		function shareList() {
			if(sessionStorage.getItem("users_info") != null) {
				location.href = '../wallet/share_list.html'
			} else {
				location.href = '../login/login.html'
			}
		}
		
		
		function copy_fn(code_name) {
			var txt = $('#' + code_name + '').text();
			Copy(txt);
		}
		// 复制微信号函数
		function Copy(str) {
			var save = function(e) {
				e.clipboardData.setData('text/plain', str);
				e.preventDefault();
			};
			document.addEventListener('copy', save);
			document.execCommand('copy');
			document.removeEventListener('copy', save);
			$.toast('复制成功', "text");
		}
		$('.share-nav span').click(function(){
			$('.share-nav span').removeClass('active-span');
			$(this).addClass('active-span');
		})
	</script>
</html>
